package com.example.demo.utils;

import com.example.demo.entity.SysRole;
import com.example.demo.entity.TreeData;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Administrator
 * @className wuyp
 * @description:
 * @Date 2022/3/25 14:18
 **/
public class MD5Sreat {

    private static TreeData treeData;
    private static ArrayList<TreeData> treeDataChildren;
    private  static  TreeData child;
    public  static   Object jiami(String username,String pwd){
        String hashAlgorithName = "MD5";
        //加密密码
        String password = pwd;
        //加密次数
        int hashIterations = 1024;
        //帐号做为加密的盐值
        ByteSource credentialsSalt = ByteSource.Util.bytes(username);
        Object obj = new SimpleHash(hashAlgorithName, password, credentialsSalt, hashIterations);
        System.out.println("obj=="+obj);
        return  obj.toString();
    }

    public static TreeData digui(SysRole role){
        treeDataChildren =new ArrayList<TreeData>();
        treeData =new TreeData();
        treeData.setTitle(role.getName());
        treeData.setId(role.getIdx());
            for(SysRole re:role.getChildren()){
                if(role.getChildren().size()>0){
                child =new TreeData();
                child.setId(re.getIdx());
                child.setTitle(re.getName());
                treeDataChildren.add(child);
                }
              treeData.setChildren(treeDataChildren);
                digui(re);
        }

        return  treeData;
    }

    public static void main(String[] args) {
        jiami("admin","123456");
    }

}
